package com.cryptoneedle.center.mapping.service;

import com.bubbles.engine.data.core.repository.BaseRepository;
import com.bubbles.engine.data.core.service.BaseService;
import com.cryptoneedle.center.common.entity.mapping.MappingColumn;
import com.cryptoneedle.center.common.key.ColumnKey;
import com.cryptoneedle.center.common.key.TableKey;
import com.cryptoneedle.center.common.repository.mapping.MappingColumnRepository;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>description:  </p>
 *
 * @author CryptoNeedle
 * @date 2025-09-26
 */
@Service
@Slf4j
public class MappingColumnService extends BaseService<MappingColumn, ColumnKey> {

    @Resource
    private MappingColumnRepository mappingColumnRepository;


    @Override
    public BaseRepository<MappingColumn, ColumnKey> getRepository() {
        return this.mappingColumnRepository;
    }

    public List<MappingColumn> listByTable(TableKey tableKey) {
        return mappingColumnRepository.listByTable(tableKey.getCatalogName(), tableKey.getDatabaseName(), tableKey.getTableName());
    }

    public List<MappingColumn> listByTable(String catalogName, String databaseName, String tableName){
        return mappingColumnRepository.listByTable(catalogName, databaseName, tableName);
    }
}